package com.niit.activity3_6.controller;


import com.niit.activity3_6.domain.Employee;
import com.niit.activity3_6.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    @GetMapping("/employee/{id}")
    public Employee getOneEmployee(@PathVariable String id){
        return employeeService.findOneById(id);
    }
    @GetMapping("/employee/gender/{gender}")
    public List<Employee> getEmployeesByGender(@PathVariable String gender){
        return employeeService.findManyByGender(gender);
    }
    @GetMapping("/employee")
    public List<Employee> getAllEmployees(){
        return employeeService.findAll();
    }
    @PostMapping("/employee")
    public void addOneEmployee(@RequestBody Employee employee){
        employeeService.addEmployee(employee);
    }
    @PutMapping("/employee")
    public void update(@RequestBody Employee employee){
        employeeService.update(employee);
    }
    @DeleteMapping("/employee/{id}")
    public void delete(@PathVariable String id){
        employeeService.deleteById(id);
    }
}